package io.coderyeah.ymcc.feign.fallback;

import feign.hystrix.FallbackFactory;
import io.coderyeah.ymcc.feign.client.MediaServiceClient;
import io.coderyeah.ymcc.result.JSONResult;
import org.springframework.stereotype.Component;

@Component
public class MediaClientFallback implements FallbackFactory<MediaServiceClient> {

    @Override
    public MediaServiceClient create(Throwable throwable) {
        return id -> {
            throwable.printStackTrace();
            return JSONResult.error(throwable.getMessage());
        };
    }
}
